/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-08-28
 * Time: 22:27
 */
public class Solution {
    // 哈希映射, 不一定非得用 map 啊老铁
    public boolean canConstruct(String ransomNote, String magazine) {
        if (magazine.length() < ransomNote.length()) {
            return false;
        }
        int[] count = new int[26];
        for (Character c: magazine.toCharArray()) {
            count[c-'a']++;
        }
        for (Character c: ransomNote.toCharArray()) {
            if (count[c-'a'] <= 0) {
                return false;
            }
            count[c-'a']--;
        }
        return true;
    }
}
